package cn.evolify.jfinaldemo.service.impl;

import cn.evolify.jfinaldemo.base.R;
import cn.evolify.jfinaldemo.model.User;
import cn.evolify.jfinaldemo.service.IUserService;
import com.jfinal.core.Controller;

/**
 * Created by wolf on 2017/2/21.
 **/
public class UserService implements IUserService{

    private Controller controller;

    public UserService(Controller controller){
        this.controller=controller;
    }

    public boolean login(String userName, String password) {
        User user=User.dao.findByUserName(userName);
        if (user!=null && password.trim().equals(user.getPassword())){
            controller.setSessionAttr(R.SessionKey.USER,user);
            return true;
        }
        return false;
    }

    public boolean logout(User user) {
        return false;
    }
}
